# -*- coding: utf-8 -*-
"""
Created on Tue May  7 15:48:19 2019
@author: Soly Liang

"""
import TrainTree as tt
from DrawTree import draw
import numpy as np
from matplotlib import pyplot as plt

# 表4.3 西瓜数据集3.0
FeatureName=['色泽','根蒂','敲声','纹理','脐部','触感','密度','含糖率']
LabelName={1:'好瓜',0:'坏瓜'}
X=[['青绿','蜷缩','浊响','清晰','凹陷','硬滑',0.697,0.460],
   ['乌黑','蜷缩','沉闷','清晰','凹陷','硬滑',0.774,0.376],
   ['乌黑','蜷缩','浊响','清晰','凹陷','硬滑',0.634,0.264],
   ['青绿','蜷缩','沉闷','清晰','凹陷','硬滑',0.608,0.318],
   ['浅白','蜷缩','浊响','清晰','凹陷','硬滑',0.556,0.215],
   ['青绿','稍蜷','浊响','清晰','稍凹','软粘',0.403,0.237],
   ['乌黑','稍蜷','浊响','稍糊','稍凹','软粘',0.481,0.149],
   ['乌黑','稍蜷','浊响','清晰','稍凹','硬滑',0.437,0.211],
   ['乌黑','稍蜷','沉闷','稍糊','稍凹','硬滑',0.666,0.091],
   ['青绿','硬挺','清脆','清晰','平坦','软粘',0.243,0.267],
   ['浅白','硬挺','清脆','模糊','平坦','硬滑',0.245,0.057],
   ['浅白','蜷缩','浊响','模糊','平坦','软粘',0.343,0.099],
   ['青绿','稍蜷','浊响','稍糊','凹陷','硬滑',0.639,0.161],
   ['浅白','稍蜷','沉闷','稍糊','凹陷','硬滑',0.657,0.198],
   ['乌黑','稍蜷','浊响','清晰','稍凹','软粘',0.360,0.370],
   ['浅白','蜷缩','浊响','模糊','平坦','硬滑',0.593,0.042],
   ['青绿','蜷缩','沉闷','稍糊','稍凹','硬滑',0.719,0.103]]
Y=[1]*8+[0]*9

#------------数据集3.0训练结果-------------- 

tree=tt.CreatTree(X,Y,FeatureName,LabelName)
print('数据集3.0训练结果：\n',tree)
draw(tree)

#------------数据集3.0α训练结果-------------- 

X=[i[-2:] for i in X]  #在数据集3.0基础上去掉最后两列即是数据集2.0
FeatureName=FeatureName[-2:]
tree=tt.CreatTree(X,Y,FeatureName,LabelName)
print('数据集3.0α训练结果：\n',tree)
draw(tree)

#------------观察3.0α训练到的多变量决策划分线---------
